<template>
  <div class="newsInfo">
    <van-panel :title="newsInfo.zhaiyao" :status="`阅读${newsInfo.click}次`">
      <div class="content">{{newsInfo.content}}</div>
    </van-panel>
    <Comment></Comment>
  </div>
</template>

<script>
import Comment from '../../../components/Comment'
export default {
  props: ['id'], // 路由传递过来的参数
  data () {
    return {
      newsInfo: {} // 使用对象,单个,不用遍历直接引用
    }
  },
  created () {
    this.getNewsInfo()
  },
  components: {
    Comment
  },
  methods: {
    async getNewsInfo () {
      const res = await this.$http.getNewsInfo(this.id) // this.id,通过api请求传递过来了的参数
      this.newsInfo = res.data.message
      console.log(this.newsInfo)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
